package cn.edu.bzu.group4.stockplus.controller;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cn.edu.bzu.group4.stockplus.service.NewsServiceImpl;

@Controller("newsController")
@RequestMapping("/news")
public class NewsController{
	private NewsServiceImpl newsserviceimpl = null;
	private ModelAndView mv = null;
	@Autowired
	public void setNewsServiceImpl(NewsServiceImpl newsserviceimpl){
		this.newsserviceimpl = newsserviceimpl;
	}
	
	
	@RequestMapping(method={RequestMethod.GET})
	public ModelAndView getNews(){
		
		Map<String,String> newsmap = new HashMap<String, String>();
		mv = new ModelAndView("news");
		System.out.println("========"+newsserviceimpl);
		
		if(newsserviceimpl.getNews() == null){
			mv.addObject("newsmap", "no news!!!!");
		//	newsmap.put("newsjsonlist", "no news");
		}else{
			mv.addObject("newsmap",newsserviceimpl.getNews().toString());
		}
		
		return mv;
	}
}
